
using System;
using UnityEngine;

public class SingleInstance<T> where T: class, new()
{
    protected static T ms_instance;
    //public static T Instance
    //{
    //    get
    //    {
    //        return ms_instance;
    //    }
    //}
    public static T Instance
    {
        get
        {
            if (ms_instance == null)
            {
                ms_instance = new T();
            }
            return ms_instance;
        }
    }

    protected SingleInstance() { }
}

public class SingleInstance_<T>
{
    protected static T ms_instance = Activator.CreateInstance<T>();
    public static T Instance
    {
        get
        {
            return ms_instance;
        }
    }
}